<#include "../header.html">
<script type="text/javascript">
	(function(window){
		var upload={
			initUpload:function(){
				$("#imgFile").change(Upload.checkUpload);
			},
			checkUpload:function(){
				var imgFile = $("#imgFile").val();
				if(imgFile==null || JFT.isBlank(imgFile)){
					alert("请选择上传文件");
					return;
				}
				if(!JFT.checkFile(imgFile, "apk")){
					alert("上传文件格式必须是[apk]");
					return;
				}
				$("#appUrlApk", parent.document).val("上传中,请等待");
				$("#uploadBtnApk", parent.document).attr("disabled",true);
				document.uploadForm.submit();
			},
			handleUpload:function(code, imgSrc){
				$("#uploadBtnApk", parent.document).attr("disabled",false);
				$("#appUrlApk", parent.document).html("上传文件");
				if(code == 0) {
					alert("上传成功");
					$("#appUrlApk", parent.document).val(imgSrc);
					return;
				}else if(code == 1){
					alert("上传失败");
					return;
				}else if(code == 3) {
					alert("不支持的扩展名");
					return;
				}
			}
		};
		window.Upload = upload;
	})(window);
	$(function(){
	<#if resultCode?string != "-1">
				Upload.handleUpload("${resultCode!}", "${imgSrc!}");
	</#if>
		Upload.initUpload();
	});
</script>
<form id="uploadForm" name="uploadForm" method="post" action="appAction.do?method=upload&type=1" enctype="multipart/form-data">
	<input type="hidden" id="imgSrc" name="imgSrc" value="${imgSrc!}"/>
	<input type="file" id="imgFile" name="imgFile"/>
</form>

<#include "../footer.html">